<?php
$page=$_SERVER['REQUEST_URI'];
if(isset($_SESSION['id_user']))
{
	$id_user = $_SESSION['id_user'];
	include_once('accessoires/connect_bdd.php');
	$sql="SELECT * FROM users WHERE id_user= :id_user;";
	$query=$connect->prepare($sql);
	$query->bindParam(':id_user',$id_user,PDO::PARAM_STR,35);
	$query->execute();
	$info_user=$query->fetch(PDO::FETCH_ASSOC);
	$pseudo = $info_user['pseudo'];
}
	switch($page){
		case "/club.php":
						$class[0]='class="active"';
						$class[1]='<span class="sr-only">(curent)</span>';
						break;
		case "/jeu_de_role.php":
						$class[2] = 'active';
						$class[3]='<span class="sr-only">(curent)</span>';
						$class[4]='class="active"';
						$class[5]='<span class="sr-only">(curent)</span>';
						break;
		case "/jeux_de_plateaux.php":
						$class[2] = 'active';
						$class[3]='<span class="sr-only">(curent)</span>';
						$class[6]='class="active"';
						$class[7]='<span class="sr-only">(curent)</span>';
						break;
		case "/actualite.php":
						$class[8]='class="active"';
						$class[9]='<span class="sr-only">(curent)</span>';
						break;
		case "/forum.php":
						$class[10]='class="active"';
						$class[11]='<span class="sr-only">(curent)</span>';
						break;
		case "/contact.php":
						$class[12]='class="active"';
						$class[13]='<span class="sr-only">(curent)</span>';
						break;
		case "/profil.php":
						$class[14] = 'active';
						$class[15]='<span class="sr-only">(curent)</span>';
						$class[16]='class="active"';
						$class[17]='<span class="sr-only">(curent)</span>';
						break;
		case "/connexion.php":
						$class[14] = 'active';
						$class[15]='<span class="sr-only">(curent)</span>';
						$class[18]='class="active"';
						$class[19]='<span class="sr-only">(curent)</span>';
						break;

}
?>
<nav class="navbar navbar-inverse">
  <div class="container-fluid">
	<!-- Brand and toggle get grouped for better mobile display -->
	<div class="navbar-header">
	  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
		<span class="sr-only">Toggle navigation</span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
	  </button>
	  <a class="navbar-brand" href="<?php if($page=="/forum/forum.php"){echo "../";}?>index.php">Accueil</a>
	</div>

	<!-- Collect the nav links, forms, and other content for toggling -->
	<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
	  <ul class="nav navbar-nav">
		<li <?php if (!empty($class[0])){echo $class[0];}?>>
			<a href="club.php">
				<span class="glyphicon glyphicon-home"></span>
				 Le club
				<?php if (!empty($class[1])){echo $class[1];}?>
			</a>
		</li>
		<li class="dropdown <?php if(!empty($class[2])) echo $class[2]; ?>">
			<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
				<span class="glyphicon glyphicon-knight"></span>
				Jeux
				<?php if (!empty($class[3])){echo $class[3];}?>
				<span class="caret"></span>
			</a>
			<ul class="dropdown-menu" role="menu">
				<li <?php if (!empty($class[4])){echo $class[4];}?>>
					<a href="jeu_de_role.php">
						Jeu de rôle
						<?php if (!empty($class[5])){echo $class[5];}?>
					</a>
				</li>
				<li <?php if (!empty($class[6])){echo $class[6];}?>>
					<a href="jeux_de_plateaux.php">
						Jeux de plateau
						<?php if (!empty($class[7])){echo $class[7];}?>
					</a>
				</li>
			</ul>
		</li>
		<li <?php if (!empty($class[8])){echo $class[8];}?>>
			<a href="actualite.php">
				<span class="glyphicon glyphicon-info-sign"></span>
				Actualité
				<?php if (!empty($class[9])){echo $class[9];}?>
			</a>
		</li>
		<li <?php if (!empty($class[10])){echo $class[10];}?>>
			<a href="forum.php">
				<span class="glyphicon glyphicon-comment"></span>
				Forum
				<?php if (!empty($class[11])){echo $class[11];}?>
			</a>
		</li>
	  </ul>
	  <ul class="nav navbar-nav navbar-right">
		  <form class="navbar-form navbar-left" role="search">
			  <div class="input-group">
				  <input type="search" class="form-control" placeholder="Rechercher..." id="barre_search">
				  <span class="input-group-btn">
					<button class="btn btn-default" id="bouton_search" type="button"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
				  </span>
			  </div>
		  </form>
			<li <?php if (!empty($class[12])){echo $class[12];}?> >
				<a href="contact.php">
					<span class="glyphicon glyphicon-envelope"></span>
					Contact
					<?php if (!empty($class[13])){echo $class[13];}?>
				</a>
			</li>
			<?php if(isset($_SESSION['id_user'])){ ?><!-- Si l'utilisateur est connecté afficher -->
				<li class="dropdown <?php if(!empty($class[14])) echo $class[14]; ?>">
					<a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
						<?php echo $pseudo; ?> <span style="font-size: 11px;">(connecté)</span>
						<?php if (!empty($class[15])){echo $class[15];} ?>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu" role="menu">
						<li>
							<a href="deconnexion.php">
								<span class="glyphicon glyphicon-off"></span>
								Se déconnecter
							</a>
						</li>
						<li <?php if (!empty($class[16])){echo $class[16];}?>>
							<a href="profil.php">
								<span class="glyphicon glyphicon-user"></span>
								Profil
								<?php if (!empty($class[17])){echo $class[17];}?>
							</a>
						</li>
					</ul>
				</li>
			<?php }else { ?> <!-- Sinon afficher -->
				<li <?php if (!empty($class[18])){echo $class[18];}?> >
					<a href="connexion.php">
						<span class="glyphicon glyphicon-user"></span>
						Mon compte
						<?php if (!empty($class[19])){echo $class[19];}?>
					</a>
				</li>
			<?php } ?>
	  </ul>
	</div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>